package cn.c4ad.voa;

import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;

public class DownloadMp3Completed extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
		if (id > 0) {
			ContentValues values = new ContentValues();
			values.put(VoaContentProvider.DOWNLOAD_ID, 0);
			values.put(VoaContentProvider.DOWNLOAD_STATE,
					VoaContentProvider.DOWNLOAD_STATE_COMPLETED_ALL);

			ContentResolver contentResolver = context.getContentResolver();
			contentResolver.update(VoaContentProvider.ARTICAL_CONTENT_URI,
					values, VoaContentProvider.DOWNLOAD_ID + "=?",
					new String[] { String.valueOf(id) });
		}
	}
}
